import mockApi from "@/api/mockApi";

export default class attendanceApi {
  static attendances=[
    {"id":1,"employeeId":2,"employeeName":"李娜","attendanceDate":"2024-01-10","checkInTime":"08:55","checkOutTime":"18:05","status":30,"createTime":"2024-11-17 22:24:17","modifyTime":"2024-02-29 22:24:17"},
    {"id":2,"employeeId":1,"employeeName":"张伟","attendanceDate":"2024-08-04","checkInTime":"09:10","checkOutTime":"18:15","status":10,"createTime":"2024-05-12 22:24:17","modifyTime":"2024-08-02 22:24:17"},
    {"id":3,"employeeId":2,"employeeName":"李娜","attendanceDate":"2024-02-22","checkInTime":"08:50","checkOutTime":"17:55","status":40,"createTime":"2024-10-10 22:24:17","modifyTime":"2024-12-17 22:24:17"},
    {"id":4,"employeeId":4,"employeeName":"陈静","attendanceDate":"2024-10-16","checkInTime":"09:00","checkOutTime":"17:30","status":40,"createTime":"2024-03-05 22:24:17","modifyTime":"2024-03-14 22:24:17"},
    {"id":5,"employeeId":3,"employeeName":"王强","attendanceDate":"2024-03-10","checkInTime":"08:45","checkOutTime":"18:10","status":20,"createTime":"2024-12-14 22:24:17","modifyTime":"2024-08-02 22:24:17"},
    {"id":6,"employeeId":1,"employeeName":"张伟","attendanceDate":"2024-05-14","checkInTime":"09:05","checkOutTime":"17:50","status":40,"createTime":"2024-11-07 22:24:17","modifyTime":"2024-03-12 22:24:17"},
    {"id":7,"employeeId":2,"employeeName":"李娜","attendanceDate":"2024-02-27","checkInTime":"08:55","checkOutTime":"18:00","status":20,"createTime":"2024-01-21 22:24:17","modifyTime":"2024-04-19 22:24:17"}
  ]

  static async save (params) {
    console.log('attendanceApi save params', params)
    const response = await mockApi.operateSuccessfully()
    return response.data
  }

  static async find (params) {
    console.log('attendanceApi find params', params)
    const response = await mockApi.queryPageSuccessfully(attendanceApi.attendances)
    return response.data
  }

  static async findById (id) {
    console.log('attendanceApi findById id', id)
    let target = {}
    for (let a of attendanceApi.attendances) {
      if (a.id === id) {
        target = a
      }
    }
    const response = await mockApi.queryByIdSuccessfully(target)
    return response.data
  }

  static async del (id) {
    console.log('attendanceApi del id', id)
    const response = await mockApi.operateSuccessfully()
    return response.data
  }
}